package com.unknow.first.dapp.admin.account.controller.admin;

import static com.unknow.first.dapp.admin.account.constants.FlashSwapConstants.FLASH_SWAP_MANAGER;
import static com.unknow.first.dapp.admin.account.constants.FlashSwapConstants.FLASH_SWAP_RECORD_MANAGER;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.unknow.first.dapp.admin.account.dto.FlashSwapRecordQueryDTO;
import com.unknow.first.dapp.admin.account.mapper.FlashSwapRecord;
import com.unknow.first.dapp.admin.account.service.FlashSwapRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.cloud.annotation.SystemResource;
import org.cloud.constant.CoreConstant.AuthMethod;
import org.cloud.utils.MyBatisPlusUtil;
import org.cloud.vo.CommonApiResult;
import org.common.CommonPage;
import org.common.CommonParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/flash/swap/record/admin")
@Api(value = "管理员:闪兑交易记录API", tags = "管理员:闪兑交易记录API")
@SystemResource(path = "/flash/swap/record/admin", parentMenuCode = FLASH_SWAP_MANAGER, parentMenuName = "闪兑管理")
public class AdminFlashSwapRecordController {

    @Autowired
    private FlashSwapRecordService flashSwapRecordService;
    @GetMapping
    @ApiOperation("查询兑换记录")
    @SystemResource(value = "/list", description = "查询闪兑记录", authMethod = AuthMethod.BYUSERPERMISSION,menuCode = FLASH_SWAP_RECORD_MANAGER,menuName = "闪兑交易记录")
    public CommonApiResult<CommonPage<FlashSwapRecord>> list(FlashSwapRecordQueryDTO swapRecordQueryDTO,CommonParam commonParam) {
        QueryWrapper<FlashSwapRecord> queryWrapper = MyBatisPlusUtil.single().getPredicate(swapRecordQueryDTO);
        PageHelper.startPage(commonParam.getPage(), commonParam.getLimit(), commonParam.getSorts());
        return CommonApiResult.createSuccessResult(CommonPage.restPage(flashSwapRecordService.list(queryWrapper)));
    }
}
